import {addObj} from '../api/assessindustrial.js'
export default {
    name: "assess-industrial-add",
    data() {
        return {
            dialogVisible:false,
            formData:{
                year:"",
                companyName:"",
                parkName:"",
                floor:"",
                contractStartTm:"",
                contractEndTm:"",
                leaseTerm:"",
                leaseArea:0,
                rentPrice:0,
                monthRent:0,
                rentConcession:"",
                enterDesc:"",
                enterprise:"",
                registeredAddress:"",
                taxPlace:"",
                totalTax:0,
                innovativeResults:0,
                gdpContribute:0,
                isListCompany:'0',
                rentStatus:"",
                assessResult:"",
                remarks:""
            },
            rules: {
                year: [
                    {required: true, message: '请输入4位年份', trigger: 'blur'},
                    {
                        min: 4,
                        max: 4,
                        message: '长度必须是4位'
                    }],
                companyName: [{required: true, message: '请输入公司名称', trigger: 'blur'}],
                parkName: [{required: true, message: '请输入园区', trigger: 'blur'}],
                floor: [{required: true, message: '请输入楼层', trigger: 'blur'}],
                assessResult: [{required: true, message: '请选择考核结果', trigger: 'blur'}],
            }
        }
    },
    computed: {
        pickerStartTime() {
            let _this = this;
            return {
                disabledDate: time => {
                    if(_this.formData.contractEndTm){
                        let edtTime = _this.formData.contractEndTm.replace(/-/g, '/');

                        return time.getTime() > new Date(edtTime)

                    }

                }

            }

        },

        pickerEndTime() {
            let _this = this;

            return {
                disabledDate: time => {
                    if(_this.formData.contractStartTm){
                        let startTime = _this.formData.contractStartTm.replace(/-/g, '/');

                        return time.getTime() < new Date(startTime)

                    }

                }

            }

        }

    },
    mounted:
        function () {
            //this.getInfo(this.rentPiceId);
        },
    methods: {

        show(){
            this.dialogVisible=true;
        },
        //加载数据
        save() {
            this.$refs["formData"].validate(valid => {
                if (valid) {

                    addObj(this.formData)
                        .then(
                            response => {
                                if (response.data.code == 0) {
                                    this.$alert("保存成功");
                                    this.dialogVisible = false;

                                    //刷新父级列表
                                    this.$parent.resetList();
                                } else {
                                    this.$alert("保存失败" + response.data.code + response.data.msg);
                                }


                            }
                        )
                }
            });
        }

    }
}
